﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using TWiStEr.Math;

namespace Phys.Model.Affectors {
	public class NormalRotatorAffector : IAffector {
		/// <summary>
		/// The rotation angle in Degrees which is applied in every second
		/// </summary>
		public double Angle { get; set; }

		/// <summary>
		/// The rotation axis which around the rotation is done
		/// </summary>
		public Vector Axis;

		/// <summary>
		/// Constructs a RotateAffector which rotates the object around the Y axis by a full circle every second
		/// </summary>
		public NormalRotatorAffector() : this(360, Vector.UnitY) { }
		public NormalRotatorAffector(double angle, Vector axis) {
			Angle = angle;
			Axis = axis;
		}

		public void Affect(IObject o, double seconds) {
			if (o is RectObject) {
				RectObject r = (RectObject)o;
				r.Normal = r.Normal.Rotate(Angle.ToRadian() * seconds, Axis);
			}
		}
	}
}
